//
//  WYCmyCardCotroller.m
//  掌上还
//
//  Created by 王晓民 on 2018/1/13.
//  Copyright © 2018年 中企互联. All rights reserved.
//

#import "WYCmyCardCotroller.h"
#import "WYCbankViewController.h"
@interface WYCmyCardCotroller ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong)UITableView * tableView;
@property(nonatomic,strong)NSArray *bankimgArr;
@property(nonatomic,strong)NSArray *banktitArr;
@property(nonatomic,strong)UILabel  *bankLb;
@end

@implementation WYCmyCardCotroller

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupNav];
    
    
    //表视图设置
    
    [self setupTabelView];
}


//表视图设置

- (void)setupTabelView{
    
    _bankimgArr = @[@"bank_icon_xy", @"bank_icon_pf", @"bank_icon_ms", @"bank_icon_jt",@"bank_icon_gd",@"bank_icon_gd",@"bank_icon_pa",@"bank_icon_gs",@"bank_icon_ms"];
    _banktitArr = @[@"兴业银行", @"浦发银行", @"民生银行", @"交通银行",@"光大银行金普卡",@"光大高端白金卡",@"平安银行",@"工商银行",@"民生银行学生卡"];
    
    if (@available(iOS 11.0, *)) {
        self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    } else {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, NavHeight, ScreenWidth, ScreenHeight) style:UITableViewStylePlain];
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    self.tableView.backgroundColor = [UIColor clearColor];
    [self.view addSubview:self.tableView];
    
}

//Nav字体颜色+ 背景
- (void)setupNav {
    self.navigationItem.title = @"办卡";
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
    [self.navigationController.navigationBar setBarTintColor:wycMain];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return _banktitArr.count;
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    return 60;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"456"];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"456"];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    UIImageView  *bankBg = [[UIImageView alloc]initWithFrame:CGRectMake(20, 20, 30, 30)];
    bankBg.image =[UIImage imageNamed:[_bankimgArr objectAtIndex:indexPath.row]];
    [cell.contentView addSubview:bankBg];
    
    _bankLb = [[UILabel alloc]initWithFrame:CGRectMake(80, 20, 100, 30 )];
    _bankLb.text = [_banktitArr objectAtIndex:indexPath.row];
    _bankLb.textColor = [UIColor grayColor];
    _bankLb.font = [UIFont systemFontOfSize:13];
    [cell.contentView addSubview:_bankLb];
    UIButton  *btnBank = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    btnBank.frame = CGRectMake(ScreenWidth-80, 20,55, 25);
    [btnBank setTitle:@"申请" forState:UIControlStateNormal];
    [btnBank setTintColor:[UIColor whiteColor]];
    btnBank.layer.cornerRadius = 13;
    btnBank.layer.masksToBounds = YES;
    btnBank.backgroundColor =wycMain;
    [cell.contentView addSubview:btnBank];
    
    
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    NSString *rowString = [self.banktitArr objectAtIndex:[indexPath row]];
    WYCbankViewController  *bankView = [[WYCbankViewController alloc]init];
    bankView.bankTitle = rowString;
    
    bankView.number = indexPath.row;
    
    
    [self.navigationController pushViewController:bankView animated:YES];
}

- (void)viewWillAppear:(BOOL)animated {
    
    [super viewWillAppear:animated];
    
    self.view.backgroundColor = WYCGlobalBg;
    
    self.navigationController.navigationBar.hidden = YES;
    
    
    UIView * NavView = [[UIView alloc] init];
    NavView.frame = CGRectMake(0, 0, ScreenWidth, NavHeight);
    NavView.backgroundColor = WYCMain;
    [self.view addSubview:NavView];
    
    
    
    CALayer *bottomLineLayer = [[CALayer alloc] init];
    bottomLineLayer.frame = CGRectMake(0, NavView.bounds.size.height - 0.5, NavView.bounds.size.width, 0.5);
    bottomLineLayer.backgroundColor = WYCRGBColor(191, 191, 196).CGColor;
    [NavView.layer addSublayer:bottomLineLayer];
    
    
//    //返回按钮
//    UIButton *  backbutton = [[UIButton alloc] init];
//    [backbutton setImage:[UIImage imageNamed:@"yiwen"] forState:UIControlStateNormal];
//    [backbutton addTarget:self action:@selector(photoClick) forControlEvents:UIControlEventTouchUpInside];
//    backbutton.frame = CGRectMake(NavView.width - 96 * px, 30, 66 * px , 66 * px);
//    [NavView addSubview:backbutton];
//
//    //返回按钮
//    UIButton *  fanhuibutton = [[UIButton alloc] init];
//    [fanhuibutton setImage:[UIImage imageNamed:@"Nav_back"] forState:UIControlStateNormal];
//    [fanhuibutton addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
//    fanhuibutton.frame = CGRectMake(30 * px, 30, 66 * px , 66 * px);
//    [NavView addSubview:fanhuibutton];
    
    
    UILabel * NavRigsterLabel = [[UILabel alloc] init];
    NavRigsterLabel.frame = CGRectMake(0, titleY, NavView.width, 68 * px);
    NavRigsterLabel.textColor = [UIColor whiteColor];
    NavRigsterLabel.font = [UIFont boldSystemFontOfSize:BigFont];
    NavRigsterLabel.textAlignment = NSTextAlignmentCenter;
    NavRigsterLabel.text = @"办卡";
    [NavView addSubview:NavRigsterLabel];
}
- (void)backClick{
    
    [self.navigationController popViewControllerAnimated:YES];
}

@end

